package test;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;

import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WriteException;
import cn.com.pxto.commons.StringUtils;

public class CreateExcel {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws WriteException 
	 */
	public static void main(String[] args) throws IOException, WriteException {
		String fileName = StringUtils.long2DateString(new Date().getTime())+".xls";				
		OutputStream os=new FileOutputStream(fileName);
		jxl.write.WritableWorkbook wwb = Workbook.createWorkbook(os);
		jxl.write.WritableFont wfc = new jxl.write.WritableFont(WritableFont.COURIER, 18, WritableFont.BOLD,true);
	    jxl.write.WritableCellFormat wcfFC = new jxl.write.WritableCellFormat(wfc);
	    wcfFC.setAlignment(jxl.format.Alignment.CENTRE);
	    wcfFC.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
	    
	    jxl.write.WritableFont wfc1 = new jxl.write.WritableFont(WritableFont.COURIER,10, WritableFont.BOLD,true);
	    jxl.write.WritableCellFormat wcfFC1 = new jxl.write.WritableCellFormat(wfc1);
	    wcfFC1.setAlignment(jxl.format.Alignment.CENTRE);
	    wcfFC1.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
	    wcfFC1.setWrap(true);

    	jxl.write.WritableCellFormat wcfFC2 = new jxl.write.WritableCellFormat();
		wcfFC2.setAlignment(jxl.format.Alignment.CENTRE);
		wcfFC2.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
		wcfFC2.setWrap(true);
		

	    WritableSheet wsheet = wwb.createSheet("sheet1", 0);
	    
       	wsheet.mergeCells(0,0,4,0);
	    wsheet.addCell(new Label(0,0,"学员名单",wcfFC));
	    wsheet.addCell(new Label(0,1,"姓名",wcfFC1));
	    wsheet.addCell(new Label(1,1,"电话",wcfFC1));
	    wsheet.addCell(new Label(2,1,"学校",wcfFC1));
	    wsheet.addCell(new Label(3,1,"班级",wcfFC1));
	    wsheet.addCell(new Label(4,1,"备注",wcfFC1));	   	   	
	    wwb.write();
	    wwb.close();
	    os.close();  

	}

}
